home *** CD-ROM | disk | FTP | other *** search
- Path: isonews.bbn.hp.com!hpbblb!news
- From: Matthias Dittrich <matti>
- Newsgroups: comp.lang.c++
- Subject: Re: Question about visibility of local variables
- Date: 5 Mar 1996 08:37:19 GMT
- Organization: Hewlett-Packard Co.
- Message-ID: <4hgufv$48h@hpbblb.bbn.hp.com>
- References: <4hfkpc$9em@guardian.forbin.com>
- NNTP-Posting-Host: trabant.bbn.hp.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/712)
- X-URL: news:4hfkpc$9em@guardian.forbin.com
-
- genesis@forbin.com (Dances with Demons) wrote:
- >.........
- >The question is: When you define a variable in main(), and call another
- >function, or even when defining a local variable in a function that calls
- >another function, why are the local variables not destroyed.
- > I had a thought that maybe since main() called the function, it still had
- >control, (at least as far as variable usage went) and therefore didn't
- >free up the memory until the function is actually completed, (End
- >of the program), but I wasn't sure. Could someone please verify that this is
- >indeed the case, or refute it and give me the real reason.
- >...
- A variable defined in a block (you should do this at the begin) is valid
- till the end of the block.
-
- Good luck,
- Matthias
-
-